<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        Function.prototype.myCall = function (context, ...arg) {
            if (context === null || context === undefined) {
                context = window;
            }
            if (typeof context !== 'object' && typeof context !== 'function') {
                context = Object(context)

            }
            //给context扩展一个属性 值为fn(this)
            const sy1 = Symbol('sy1')
            context[sy1] = this
            //调用context新扩展的方法 context新增的属性所代表的fn就会调用,并把this指向context fn的返回值也会被re接收
            const re = context[sy1](...arg)
            //用完这个sy1属性 就删掉 不要对原context对象产生影响
            delete context[sy1]
            return re;
        }
        function fn(a,b){
            console.log(this,a+b);
            return 1;
        }
        console.log(fn.myCall({}, 1, 2));

    </script>
</body>

</html>